package cn.fufeiii.bt.bitcalc;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author FuFei
 */
@Getter
@AllArgsConstructor
public enum ContactTypeEnum {

    EMAIL(1), //          1 -> 0001
    WEBHOOK(1 << 1), //   2 -> 0010
    SMS(1 << 2), //       4 -> 0100
    TEL(1 << 3), //       8 -> 1000
    ;

    public static final Integer FULL_TYPE = (1 << values().length) - 1; // 15 -> 1111

    private final Integer code;

    public static ContactTypeEnum getByCode(Integer code) {
        return Arrays.stream(values()).filter(it -> it.getCode().equals(code)).findAny().orElseThrow();
    }

}